<?php
/**
 * 
 * Modelo de SMS_HeaderCI
 * @author Natanael 
 * 
 */
class HeaderCi extends Model{

         private $_nameTable = "SMS_HeaderCI";
         
         public function __construct()
         {
            parent::Model();
            $this->load->database();
         }
         
         public function loadRegistro($where = false, $start = false,$offset=false,$sortname=false,$sortorder = false)
         {


		     if($offset != false)
		        $this->db->limit($offset, $start);

		     if($sortname != false && $sortorder != false) {
			     $this->db->order_by($sortname, $sortorder);
		     }
         	
         	
             if ($where != false)
                $query = $this->db->get_where($this->_nameTable, $where);
             else 
                $query = $this->db->get($this->_nameTable);   
                
              return $this->getArrayFromQueryResult($query);
         }
         
         private function getArrayFromQueryResult($result)
         {
           if ($result->num_rows() == 0)
				      return false;
	
			 $data_arr = array();
	
			foreach ($result->result() as $record) {
				$data_arr[] = new SMSHeaderCI($record);
		    }
	
			return $data_arr;
         }
         
         public function addRegistro($data)
         {
            if ($this->db->insert($this->_nameTable, $data)){
                $dataObjeto = $this->db->get_where($this->_nameTable,$data);
                $objeto = new SMSHeaderCI($dataObjeto->row());
                return $objeto->getIdSms();
            }
            else  
              return false;  
         }
         
}

class SMSHeaderCI{

        private $_idSms = 0;
        private $_smsData = " ";
        private $_smsTime = " ";
        private $_smsEnviados = 0;
        private $_smsType = "";
        
        public function __construct($ojt)
        {
           $this->setIdSms($ojt->IdSms);
           $this->setData($ojt->Date);
           $this->setTime($ojt->Time);
           $this->setSmsEnviados($ojt->SmsEnviados);
            $this->setSmsType($ojt->Type);
        }

        public function getIdSms()
        {
           return $this->_idSms;
        }
        
        public function setIdSms($var)
        {
           $this->_idSms = $var;
        }

        public function getData()
        {
           return $this->_smsData ;
        }
        
        public function setData($var)
        {
           $this->_smsData = $var;
        }
        
        public function getTime()
        {
           return $this->_smsTime;
        }
        
        public function setTime($var)
        {
           $this->_smsTime = $var;
        }
        
        public function getSmsEnviados()
        {
           return $this->_smsEnviados ;
        }
        
        public function setSmsEnviados($var)
        {
           $this->_smsEnviados = $var;
        }
        
        public function getSmsType()
        {
           return $this->_smsType ;
        }
        
        public function setSmsType($var)
        {
           $this->_smsType = $var;
        }
}